import java.util.Calendar;
import java.util.Random;
/**
 * @autor my
 * 2017/8/29.
 */
public class RandomDate{
    //用于产生随机时间
    Calendar calendar=Calendar.getInstance();
    Random random =new Random();
    private int year=random.nextInt(30)+1970;
    private int month=random.nextInt(12)+1;
    private int day;
    private int hour=random.nextInt(24);
    private int minute=random.nextInt(60);
    private int second=random.nextInt(60);
    public  int randomDay(){
        //判断每月随机的范围
        if (month==1||month==3||month==5||month==7||month==8||month==10||month==12){
            day=random.nextInt(31)+1;
        }
        else if (month==4||month==6||month==9||month==11){
            day=random.nextInt(30)+1;
        }
        else {
            //判断二月有多少天
            if (year%4==0){
                day=random.nextInt(29)+1;
            }
            else {
                day=random.nextInt(28)+1;
            }
        }
        return day;
    }

    public int getHour() {
        return hour;
    }

    public int getMinute() {
        return minute;
    }

    public int getSecond() {
        return second;
    }
    public int getYear() {
        return year;
    } public int getMonth() {
        return month;
    } public int getDay() {
        return day;
    }
}
